<?php

namespace Yi\Permission;

use Illuminate\Support\Facades\Route;


// 添加鉴权
Route::group(['prefix' => '/api/backend'], function () {
    /**
     * 后台-用户-菜单-角色
     */
    Route::group(['prefix' => 'auth'], function () {

        Route::get('/current-user-menus', [\Yi\Permission\Http\Controllers\AdminUserLoginController::class, 'currentUserMenus'])->middleware(['auth.backend:any']);

        Route::group(['prefix' => 'menu'], function () {
            Route::get('/dict', [\Yi\Permission\Http\Controllers\Auth\MenuController::class, 'dict'])->middleware(['auth.backend:any']);
            Route::get('/tree', [\Yi\Permission\Http\Controllers\Auth\MenuController::class, 'tree'])->middleware(['auth.backend:any']);
            Route::post('', [\Yi\Permission\Http\Controllers\Auth\MenuController::class, 'create'])->middleware(['auth.backend:any']);
            Route::put('/{id}', [\Yi\Permission\Http\Controllers\Auth\MenuController::class, 'update'])->middleware(['auth.backend:any']);
            Route::delete('/{id}', [\Yi\Permission\Http\Controllers\Auth\MenuController::class, 'delete'])->middleware(['auth.backend:any']);
        });
        Route::group(['prefix' => 'role'], function () {
            Route::get('/all', [\Yi\Permission\Http\Controllers\Auth\RoleController::class, 'getLable'])->middleware(['auth.backend:any']);
            Route::get('/dict', [\Yi\Permission\Http\Controllers\Auth\RoleController::class, 'dict'])->middleware(['auth.backend:any']);
            Route::get('', [\Yi\Permission\Http\Controllers\Auth\RoleController::class, 'index'])->middleware(['auth.backend:any']);
            Route::post('', [\Yi\Permission\Http\Controllers\Auth\RoleController::class, 'create'])->middleware(['auth.backend:any']);
            Route::put('/{id}', [\Yi\Permission\Http\Controllers\Auth\RoleController::class, 'update'])->middleware(['auth.backend:any']);
            Route::delete('/{id}', [\Yi\Permission\Http\Controllers\Auth\RoleController::class, 'delete'])->middleware(['auth.backend:any']);
        });
        Route::group(['prefix' => 'user'], function () {
            Route::get('', [\Yi\Permission\Http\Controllers\Auth\UserController::class, 'index'])->middleware(['auth.backend:any']);
            Route::get('/dict', [\Yi\Permission\Http\Controllers\Auth\UserController::class, 'dict'])->middleware(['auth.backend:any']);
            Route::post('', [\Yi\Permission\Http\Controllers\Auth\UserController::class, 'create'])->middleware(['auth.backend:any']);
            Route::put('/{id}', [\Yi\Permission\Http\Controllers\Auth\UserController::class, 'update'])->middleware(['auth.backend:any']);
            Route::delete('/{id}', [\Yi\Permission\Http\Controllers\Auth\UserController::class, 'delete'])->middleware(['auth.backend:any']);
        });
    });
    //系统通用
    Route::post('/system/resource', [\Yi\Permission\Support\Aliyun\OssClient::class, 'putObject'])->middleware(['auth.backend:any']);
});
